package db.nio;


import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.util.List;
import java.util.concurrent.TimeoutException;

/**
 * 成帧器接口
 * Created by daibin on 10/17/16.
 */
public interface Framer {

    /**
     * 通道触发事件
     * @param key
     */
    void setSelectionKey(SelectionKey key);

    /**
     * 读(考虑粘包)
     * @return
     * @throws IOException
     */
    List<ByteBuffer> read() throws  Exception;

    /**
     * 写
     * @throws IOException
     */
    void write(ByteBuffer buffer) throws Exception ;


    /**
     * 关闭通道
     * @throws IOException
     */
    void close() throws IOException;


}
